import axios from 'axios'
import store from '@/store'
// import { Message } from 'element-ui'
const request = axios.create({
  baseURL: process.env.VUE_APP_BASE_API,
  timeout: 5000
})
// 添加请求拦截器
request.interceptors.request.use(config => {
  const token = store.state.user.token
  // console.log('token', token)
  if (token) {
    // config.headers.Authorization = `Bearer ${token}`
  }
  return config
}, error => {
  return Promise.reject(error)
})
// 响应拦截器
request.interceptors.response.use(response => {
  // if (response.data.success) {
  return response
  // } else {
  //   Message.error(response.data.message)
  //   return Promise.reject(response.data.message)
  // }
}, error => {
  return Promise.reject(error)
})
export default request
